// components/navtop/navtop.js
import {
  getPage
} from "../../api/index.js"
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    show: {
      type: Boolean,
      value: false,
    },
    type: {
      type: Number,
      value: 0
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    value: null,
    title:null,
  },
  ready() {
    // var res = await getPage('xieyi1')
    // res.data['6'].value = res.data['6'].value.replace(/\n/g, "<br>")
    // if (res.code == 200) {
    //   this.setData({
    //     value: res.data['6'].value
    //   })
    // }
    if(this.data.type == 1){
      getPage('xieyi2').then(res=>{
        res.data['7'].value = res.data['7'].value.replace(/<p/gi, '<p class="p_class"')
        res.data['7'].value = res.data['7'].value.replace(/\<img/gi, `<img class="img_class"`)
        res.data['7'].value = res.data['7'].value.replace(/<h1>/ig, '<h1 class="h1_class">')
        res.data['7'].value = res.data['7'].value.replace(/<h2>/ig, '<h2 class="h1_class">')
        res.data['7'].value =  res.data['7'].value.replace(/<table>/ig, '<table class="table_rich">')
        res.data['7'].value =  res.data['7'].value.replace(/<tbody>/ig, '<table class="tbody_rich">')
        res.data['7'].value =  res.data['7'].value.replace(/<tr>/gi, '<tr class="tr_rich"')
        res.data['7'].value =  res.data['7'].value.replace(/<td>/gi, '<td class="td_rich"')
        this.setData({
          value: res.data['7'].value,
          title:"远程汽车小程序隐私政策"
        })
      })
    }else{
      getPage('minixieyi').then(res=>{
        res.data['45'].value = res.data['45'].value.replace(/<p>/ig, '<p class="p_class">')
        res.data['45'].value = res.data['45'].value.replace(/<h1>/ig, '<h1 class="h1_class">')
        res.data['45'].value = res.data['45'].value.replace(/<h2>/ig, '<h2 class="h1_class">')
        this.setData({
          value: res.data['45'].value,
          title:"远程汽车小程序用户协议"
        })
      })
    }
  },
  /**
   * 组件的方法列表
   */
  methods: {
    clickNo() {
      this.setData({
        'show': false
      })
      this.triggerEvent('agreeClick', {
        'checked': false
      })
    },
    clickYes() {
      this.setData({
        'show': false
      })
      this.triggerEvent('agreeClick', {
        'checked': true
      })
    }
  }
})